home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Freeware / Miro 1.0 / Miro_Installer.exe / Miro_Downloader.exe / frontend_implementation / startup.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2007-11-12  |  2.9 KB  |  77 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. from threading import Thread, Event
  5. import util
  6. import frontend
  7. from gtcache import gettext as _
  8. from gtcache import ngettext
  9.  
  10. class _Search:
  11.     
  12.     def __init__(self, path):
  13.         self.cancelled = Event()
  14.         self.path = path
  15.         self.last = None
  16.  
  17.     
  18.     def run(self):
  19.         thread = Thread(target = self.runSearch)
  20.         thread.setDaemon(True)
  21.         thread.start()
  22.  
  23.     
  24.     def cancel(self):
  25.         self.cancelled.set()
  26.  
  27.     
  28.     def progressCallback(self, files, videos):
  29.         if self.cancelled.isSet():
  30.             return False
  31.         
  32.         frontend.jsBridge.updateSearchProgress(_('(parsed %d files - found %d videos)') % (files, videos))
  33.         return True
  34.  
  35.     
  36.     def runSearch(self):
  37.         self.files = util.gatherVideos(self.path, self.progressCallback)
  38.         if not self.cancelled.isSet():
  39.             count = len(self.files)
  40.             frontend.jsBridge.searchFinished(ngettext('%d video found', '%d videos found', count) % (count,))
  41.         
  42.  
  43.     
  44.     def getFiles(self):
  45.         if self.cancelled.isSet():
  46.             return None
  47.         else:
  48.             return self.files
  49.  
  50.  
  51. search = None
  52. callback = None
  53.  
  54. def doSearch(path):
  55.     global search
  56.     search = _Search(path)
  57.     search.run()
  58.  
  59.  
  60. def cancelSearch():
  61.     search.cancel()
  62.     frontend.jsBridge.searchCancelled('')
  63.  
  64.  
  65. def finishStartup():
  66.     if search:
  67.         terminationCallback(search.getFiles())
  68.     else:
  69.         terminationCallback(None)
  70.  
  71.  
  72. def performStartupTasks(terminationCallback):
  73.     global callback
  74.     callback = terminationCallback
  75.     frontend.jsBridge.performStartupTasks(os.path.expanduser('~'))
  76.  
  77.